package merlin.managers;

import java.sql.*;

import merlin.beans.*;
import merlin.dao.*;

public class LookupDetailsManager{

	public static DbResultSet selectTopLookupDetailsByKeywordRecords(String whereClause,String orderByClause,int maxRecords){
		DbResultSet result = null;
		Connection con=null;
		ConnectionPool pool = null;
		try{
			pool = ConnectionPool.getConnectionPool("researcher");
			con = pool.getConnection();

			LookupDetailsDAO dao = new LookupDetailsDAO(con);
			result = dao.selectTopLookupDetailsByKeywordRecords(whereClause,orderByClause,maxRecords);
		}catch(Exception e){
			System.err.println(e);
			throw new RuntimeException(e);
		}finally{
			pool.returnConnection(con);
			con=null;
		}
		return result;
	}

	public static DbResultSet selectLookupDetailsRecords(String whereClause,String orderByClause){
		DbResultSet result = null;
		Connection con=null;
		ConnectionPool pool = null;
		try{
			pool = ConnectionPool.getConnectionPool("researcher");
			con = pool.getConnection();

			LookupDetailsDAO dao = new LookupDetailsDAO(con);
			result = dao.selectLookupDetailsRecords(whereClause,orderByClause);
		}catch(Exception e){
			System.err.println(e);
			throw new RuntimeException(e);
		}finally{
			pool.returnConnection(con);
			con=null;
		}
		return result;
	}

	public static LookupDetailsBean selectLookupDetailsByPK(String pk){
		LookupDetailsBean bean = null;
		Connection con=null;
		ConnectionPool pool = null;
		try{
			pool = ConnectionPool.getConnectionPool("researcher");
			con = pool.getConnection();

			LookupDetailsDAO dao = new LookupDetailsDAO(con);
			bean = dao.selectLookupDetailsByPK(pk);
		}catch(Exception e){
			System.err.println(e);
			throw new RuntimeException(e);
		}finally{
			pool.returnConnection(con);
			con=null;
		}
		return bean;
	}
	public static DbResultSet selectLookupDetailsRecordsByDirector(String director){
		DbResultSet result = null;
		Connection con=null;
		ConnectionPool pool = null;
		try{
			pool = ConnectionPool.getConnectionPool("researcher");
			con = pool.getConnection();

			LookupDetailsDAO dao = new LookupDetailsDAO(con);
			result = dao.selectLookupDetailsRecordsByDirector(director);
		}catch(Exception e){
			System.err.println(e);
			throw new RuntimeException(e);
		}finally{
			pool.returnConnection(con);
			con=null;
		}
		return result;
	}
}